/*
 * TCSS 360 - Winter 2014
 * TESK Software
 */
package view.Papers;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

/**
 * This is a static class for copying files from 1 location to another
 * 
 * @author Thang
 * @version March 2014
 */
public class CopyDocuments {

	/**
	 * This is the static method that copies a file.
	 * 
	 * @param source old to be copied from
	 * @param target new File("PathName/FileName")
	 * @throws IOException
	 */
	static public void copy(File source, File target) throws IOException {
		  
        FileChannel sourceChannel = null;    
        FileChannel targetChannel = null;    
        try {    
            sourceChannel = new FileInputStream(source).getChannel();    
            targetChannel=  new FileOutputStream(target).getChannel();    
	        targetChannel.transferFrom(sourceChannel, 0,    
	        sourceChannel.size());    
        }    
        finally {    
	       targetChannel.close();    
	       sourceChannel.close();    
        }    
	}
}
